<template>
  <div class="app-container">
    <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="68px">
      <el-form-item label="员工姓名" prop="employeeName">
        <el-input
          v-model="queryParams.employeeName"
          placeholder="请输入员工姓名"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="工号" prop="jobNumber">
        <el-input
          v-model="queryParams.jobNumber"
          placeholder="请输入工号"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item>
        <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
        <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
      </el-form-item>
    </el-form>

    <el-row :gutter="10" class="mb8">
      <el-col :span="1.5">
        <el-button
          type="primary"
          plain
          icon="el-icon-plus"
          size="mini"
          @click="handleAdd"
          v-hasPermi="['hr:rgAttend:add']"
        >新增
        </el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="success"
          plain
          icon="el-icon-edit"
          size="mini"
          :disabled="single"
          @click="handleUpdate"
          v-hasPermi="['hr:rgAttend:edit']"
        >修改
        </el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="danger"
          plain
          icon="el-icon-delete"
          size="mini"
          :disabled="multiple"
          @click="handleDelete"
          v-hasPermi="['hr:rgAttend:remove']"
        >删除
        </el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="warning"
          plain
          icon="el-icon-download"
          size="mini"
          @click="handleExport"
          v-hasPermi="['hr:rgAttend:export']"
        >导出
        </el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="info"
          plain
          icon="el-icon-upload2"
          size="mini"
          @click="handleImport"
        >导入
        </el-button>
      </el-col>
      <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
    </el-row>

    <el-table v-loading="loading" :data="rgAttendList" @selection-change="handleSelectionChange"
              :span-method="objectSpanMethod" border>
      <el-table-column type="selection" width="55" align="center"/>
      <el-table-column label="公司名称" align="center" prop="gcName" width="120"/>
      <el-table-column label="员工姓名" align="center" prop="employeeName" width="120"/>
      <el-table-column label="工号" align="center" prop="jobNumber" width="140"/>
      <el-table-column label="部门" align="center" prop="department" width="120"/>
      <el-table-column label="分部" align="center" prop="branch" width="120"/>
      <el-table-column label="入职日期" align="center" prop="rzDate" width="140">
        <template slot-scope="scope">
          <span>{{ parseTime(scope.row.rzDate, '{y}-{m}-{d}') }}</span>
        </template>
      </el-table-column>
      <el-table-column label="组别" align="center" prop="zb"/>
      <el-table-column label="岗位" align="center" prop="jobs"/>
      <el-table-column label="月份" align="center" prop="kqDate" width="180"/>
      <el-table-column label="1日" align="center" prop="day1">
        <template slot-scope="scope">
          <el-select v-model="scope.row.day1" placeholder="" clearable @change="wrChangeMethod(scope.row.id,scope.row.day1,'day1')">
            <el-option
              v-for="dict in dict.type.wr_type"
              :key="dict.value"
              :label="dict.label"
              :value="dict.value"
            />
          </el-select>
        </template>
      </el-table-column>
      <el-table-column label="2日" align="center" prop="day2">
        <template slot-scope="scope">
          <el-select v-model="scope.row.day2" placeholder="" clearable  @change="wrChangeMethod(scope.row.id,scope.row.day2,'day2')">
            <el-option
              v-for="dict in dict.type.wr_type"
              :key="dict.value"
              :label="dict.label"
              :value="dict.value"
            />
          </el-select>
        </template>
      </el-table-column>

      <el-table-column label="3日" align="center" prop="day3">
        <template slot-scope="scope">
          <el-select v-model="scope.row.day3" placeholder="" clearable @change="wrChangeMethod(scope.row.id,scope.row.day3,'day3')">
            <el-option
              v-for="dict in dict.type.wr_type"
              :key="dict.value"
              :label="dict.label"
              :value="dict.value"
            />
          </el-select>
        </template>
      </el-table-column>
      <el-table-column label="4日" align="center" prop="day4">
        <template slot-scope="scope">
          <el-select v-model="scope.row.day4" placeholder="" clearable @change="wrChangeMethod(scope.row.id,scope.row.day4,'day4')">
            <el-option
              v-for="dict in dict.type.wr_type"
              :key="dict.value"
              :label="dict.label"
              :value="dict.value"
            />
          </el-select>
        </template>
      </el-table-column>
      <el-table-column label="5日" align="center" prop="day5">
        <template slot-scope="scope">
          <el-select v-model="scope.row.day5" placeholder="" clearable @change="wrChangeMethod(scope.row.id,scope.row.day5,'day5')">
            <el-option
              v-for="dict in dict.type.wr_type"
              :key="dict.value"
              :label="dict.label"
              :value="dict.value"
            />
          </el-select>
        </template>
      </el-table-column>
      <el-table-column label="6日" align="center" prop="day6">
        <template slot-scope="scope">
          <el-select v-model="scope.row.day6" placeholder="" clearable @change="wrChangeMethod(scope.row.id,scope.row.day6,'day6')">
            <el-option
              v-for="dict in dict.type.wr_type"
              :key="dict.value"
              :label="dict.label"
              :value="dict.value"
            />
          </el-select>
        </template>
      </el-table-column>
      <el-table-column label="7日" align="center" prop="day7">
        <template slot-scope="scope">
          <el-select v-model="scope.row.day7" placeholder="" clearable @change="wrChangeMethod(scope.row.id,scope.row.day7,'day7')">
            <el-option
              v-for="dict in dict.type.wr_type"
              :key="dict.value"
              :label="dict.label"
              :value="dict.value"
            />
          </el-select>
        </template>
      </el-table-column>
      <el-table-column label="8日" align="center" prop="day8">
        <template slot-scope="scope">
          <el-select v-model="scope.row.day8" placeholder="" clearable @change="wrChangeMethod(scope.row.id,scope.row.day8,'day8')">
            <el-option
              v-for="dict in dict.type.wr_type"
              :key="dict.value"
              :label="dict.label"
              :value="dict.value"
            />
          </el-select>
        </template>
      </el-table-column>
      <el-table-column label="9日" align="center" prop="day9">
        <template slot-scope="scope">
          <el-select v-model="scope.row.day9" placeholder="" clearable @change="wrChangeMethod(scope.row.id,scope.row.day9,'day9')">
            <el-option
              v-for="dict in dict.type.wr_type"
              :key="dict.value"
              :label="dict.label"
              :value="dict.value"
            />
          </el-select>
        </template>
      </el-table-column>
      <el-table-column label="10日" align="center" prop="day10">
        <template slot-scope="scope">
          <el-select v-model="scope.row.day10" placeholder="" clearable @change="wrChangeMethod(scope.row.id,scope.row.day10,'day10')">
            <el-option
              v-for="dict in dict.type.wr_type"
              :key="dict.value"
              :label="dict.label"
              :value="dict.value"
            />
          </el-select>
        </template>
      </el-table-column>
      <el-table-column label="11日" align="center" prop="day11">
        <template slot-scope="scope">
          <el-select v-model="scope.row.day11" placeholder="" clearable @change="wrChangeMethod(scope.row.id,scope.row.day11,'day11')">
            <el-option
              v-for="dict in dict.type.wr_type"
              :key="dict.value"
              :label="dict.label"
              :value="dict.value"
            />
          </el-select>
        </template>
      </el-table-column>
      <el-table-column label="12日" align="center" prop="day12">
        <template slot-scope="scope">
          <el-select v-model="scope.row.day12" placeholder="" clearable @change="wrChangeMethod(scope.row.id,scope.row.day12,'day12')">
            <el-option
              v-for="dict in dict.type.wr_type"
              :key="dict.value"
              :label="dict.label"
              :value="dict.value"
            />
          </el-select>
        </template>
      </el-table-column>
      <el-table-column label="13日" align="center" prop="day13">
        <template slot-scope="scope">
          <el-select v-model="scope.row.day13" placeholder="" clearable @change="wrChangeMethod(scope.row.id,scope.row.day13,'day13')">
            <el-option
              v-for="dict in dict.type.wr_type"
              :key="dict.value"
              :label="dict.label"
              :value="dict.value"
            />
          </el-select>
        </template>
      </el-table-column>
      <el-table-column label="14日" align="center" prop="day14">
        <template slot-scope="scope">
          <el-select v-model="scope.row.day14" placeholder="" clearable @change="wrChangeMethod(scope.row.id,scope.row.day14,'day14')">
            <el-option
              v-for="dict in dict.type.wr_type"
              :key="dict.value"
              :label="dict.label"
              :value="dict.value"
            />
          </el-select>
        </template>
      </el-table-column>
      <el-table-column label="15日" align="center" prop="day15">
        <template slot-scope="scope">
          <el-select v-model="scope.row.day15" placeholder="" clearable @change="wrChangeMethod(scope.row.id,scope.row.day15,'day15')">
            <el-option
              v-for="dict in dict.type.wr_type"
              :key="dict.value"
              :label="dict.label"
              :value="dict.value"
            />
          </el-select>
        </template>
      </el-table-column>
      <el-table-column label="16日" align="center" prop="day16">
        <template slot-scope="scope">
          <el-select v-model="scope.row.day16" placeholder="" clearable @change="wrChangeMethod(scope.row.id,scope.row.day16,'day16')">
            <el-option
              v-for="dict in dict.type.wr_type"
              :key="dict.value"
              :label="dict.label"
              :value="dict.value"
            />
          </el-select>
        </template>
      </el-table-column>
      <el-table-column label="17日" align="center" prop="day17">
        <template slot-scope="scope">
          <el-select v-model="scope.row.day17" placeholder="" clearable @change="wrChangeMethod(scope.row.id,scope.row.day17,'day17')">
            <el-option
              v-for="dict in dict.type.wr_type"
              :key="dict.value"
              :label="dict.label"
              :value="dict.value"
            />
          </el-select>
        </template>
      </el-table-column>
      <el-table-column label="18日" align="center" prop="day18">
        <template slot-scope="scope">
          <el-select v-model="scope.row.day18" placeholder="" clearable @change="wrChangeMethod(scope.row.id,scope.row.day18,'day18')">
            <el-option
              v-for="dict in dict.type.wr_type"
              :key="dict.value"
              :label="dict.label"
              :value="dict.value"
            />
          </el-select>
        </template>
      </el-table-column>
      <el-table-column label="19日" align="center" prop="day19">
        <template slot-scope="scope">
          <el-select v-model="scope.row.day19" placeholder="" clearable @change="wrChangeMethod(scope.row.id,scope.row.day19,'day19')">
            <el-option
              v-for="dict in dict.type.wr_type"
              :key="dict.value"
              :label="dict.label"
              :value="dict.value"
            />
          </el-select>
        </template>
      </el-table-column>
      <el-table-column label="20日" align="center" prop="day20">
        <template slot-scope="scope">
          <el-select v-model="scope.row.day20" placeholder="" clearable @change="wrChangeMethod(scope.row.id,scope.row.day20,'day20')">
            <el-option
              v-for="dict in dict.type.wr_type"
              :key="dict.value"
              :label="dict.label"
              :value="dict.value"
            />
          </el-select>
        </template>
      </el-table-column>
      <el-table-column label="21日" align="center" prop="day21">
        <template slot-scope="scope">
          <el-select v-model="scope.row.day21" placeholder="" clearable @change="wrChangeMethod(scope.row.id,scope.row.day21,'day21')">
            <el-option
              v-for="dict in dict.type.wr_type"
              :key="dict.value"
              :label="dict.label"
              :value="dict.value"
            />
          </el-select>
        </template>
      </el-table-column>
      <el-table-column label="22日" align="center" prop="day22">
        <template slot-scope="scope">
          <el-select v-model="scope.row.day22" placeholder="" clearable @change="wrChangeMethod(scope.row.id,scope.row.day22,'day22')">
            <el-option
              v-for="dict in dict.type.wr_type"
              :key="dict.value"
              :label="dict.label"
              :value="dict.value"
            />
          </el-select>
        </template>
      </el-table-column>
      <el-table-column label="23日" align="center" prop="day23">
        <template slot-scope="scope">
          <el-select v-model="scope.row.day23" placeholder="" clearable @change="wrChangeMethod(scope.row.id,scope.row.day23,'day23')">
            <el-option
              v-for="dict in dict.type.wr_type"
              :key="dict.value"
              :label="dict.label"
              :value="dict.value"
            />
          </el-select>
        </template>
      </el-table-column>
      <el-table-column label="24日" align="center" prop="day24">
        <template slot-scope="scope">
          <el-select v-model="scope.row.day24" placeholder="" clearable @change="wrChangeMethod(scope.row.id,scope.row.day24,'day24')">
            <el-option
              v-for="dict in dict.type.wr_type"
              :key="dict.value"
              :label="dict.label"
              :value="dict.value"
            />
          </el-select>
        </template>
      </el-table-column>
      <el-table-column label="25日" align="center" prop="day25">
        <template slot-scope="scope">
          <el-select v-model="scope.row.day25" placeholder="" clearable @change="wrChangeMethod(scope.row.id,scope.row.day25,'day25')">
            <el-option
              v-for="dict in dict.type.wr_type"
              :key="dict.value"
              :label="dict.label"
              :value="dict.value"
            />
          </el-select>
        </template>
      </el-table-column>
      <el-table-column label="26日" align="center" prop="day26">
        <template slot-scope="scope">
          <el-select v-model="scope.row.day26" placeholder="" clearable @change="wrChangeMethod(scope.row.id,scope.row.day26,'day26')">
            <el-option
              v-for="dict in dict.type.wr_type"
              :key="dict.value"
              :label="dict.label"
              :value="dict.value"
            />
          </el-select>
        </template>
      </el-table-column>
      <el-table-column label="27日" align="center" prop="day27">
        <template slot-scope="scope">
          <el-select v-model="scope.row.day27" placeholder="" clearable @change="wrChangeMethod(scope.row.id,scope.row.day27,'day27')">
            <el-option
              v-for="dict in dict.type.wr_type"
              :key="dict.value"
              :label="dict.label"
              :value="dict.value"
            />
          </el-select>
        </template>
      </el-table-column>
      <el-table-column label="28日" align="center" prop="day28">
        <template slot-scope="scope">
          <el-select v-model="scope.row.day28" placeholder="" clearable @change="wrChangeMethod(scope.row.id,scope.row.day28,'day28')">
            <el-option
              v-for="dict in dict.type.wr_type"
              :key="dict.value"
              :label="dict.label"
              :value="dict.value"
            />
          </el-select>
        </template>
      </el-table-column>
      <el-table-column label="29日" align="center" prop="day29">
        <template slot-scope="scope">
          <el-select v-model="scope.row.day29" placeholder="" clearable @change="wrChangeMethod(scope.row.id,scope.row.day29,'day29')">
            <el-option
              v-for="dict in dict.type.wr_type"
              :key="dict.value"
              :label="dict.label"
              :value="dict.value"
            />
          </el-select>
        </template>
      </el-table-column>
      <el-table-column label="30日" align="center" prop="day30">
        <template slot-scope="scope">
          <el-select v-model="scope.row.day30" placeholder="" clearable @change="wrChangeMethod(scope.row.id,scope.row.day30,'day30')">
            <el-option
              v-for="dict in dict.type.wr_type"
              :key="dict.value"
              :label="dict.label"
              :value="dict.value"
            />
          </el-select>
        </template>
      </el-table-column>
      <el-table-column label="31日" align="center" prop="day31">
        <template slot-scope="scope">
          <el-select v-model="scope.row.day31" placeholder="" clearable @change="wrChangeMethod(scope.row.id,scope.row.day31,'day31')">
            <el-option
              v-for="dict in dict.type.wr_type"
              :key="dict.value"
              :label="dict.label"
              :value="dict.value"
            />
          </el-select>
        </template>
      </el-table-column>
      <el-table-column label="实到天数" align="center" prop="actDays"/>
      <el-table-column label="节假日加班(小时)" align="center" prop="jjrTime" width="140">
      </el-table-column>
      <el-table-column label="正常加班(小时)" align="center" prop="jbTime" width="120">
      </el-table-column>
      <el-table-column label="拖班时间(小时)" align="center" prop="tbTime" width="120"/>
      <el-table-column label="实到小时" align="center" prop="sdTime"/>
      <el-table-column label="休班天数" align="center" prop="restDay"/>
      <el-table-column label="假期天数" align="center" prop="leaveDay"/>
      <el-table-column label="轮休天数" align="center" prop="lunDay"/>
      <el-table-column label="新离职缺勤天数" align="center" prop="xlzqqDay" width="180"/>
      <el-table-column label="应出勤天数" align="center" prop="ycqDay" width="150"/>
      <el-table-column label="操作" align="center" class-name="small-padding fixed-width" fixed="right" width="160">
        <template slot-scope="scope">
          <el-button
            size="mini"
            type="text"
            icon="el-icon-edit"
            @click="handleUpdate(scope.row)"
            v-hasPermi="['hr:rgAttend:edit']"
          >修改
          </el-button>
          <el-button
            size="mini"
            type="text"
            icon="el-icon-delete"
            @click="handleDelete(scope.row)"
            v-hasPermi="['hr:rgAttend:remove']"
          >删除
          </el-button>
        </template>
      </el-table-column>
    </el-table>

    <pagination
      v-show="total>0"
      :total="total"
      :page.sync="queryParams.pageNum"
      :limit.sync="queryParams.pageSize"
      @pagination="getList"
    />

    <!-- 添加或修改人工考勤对话框 -->
    <el-dialog :title="title" :visible.sync="open" width="1000px" append-to-body>
      <el-form ref="form" :model="form" :rules="rules" label-width="120px">
        <el-row>
          <el-col :span="8">
            <el-form-item label="工号" prop="jobNumber">
              <el-input v-model="form.jobNumber" placeholder="请选择员工" readonly>
                <el-button slot="append" icon="el-icon-search" @click="handleSelectPerson"></el-button>
              </el-input>
            </el-form-item>
            <PersonSelect ref="personSelect" @onSelected="onPersonSelected" ></PersonSelect>
          </el-col>
          <el-col :span="8">
            <el-form-item label="姓名" prop="employeeName">
              <el-input v-model="form.employeeName" placeholder="" readonly/>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="部门" prop="department">
              <el-input v-model="form.department" placeholder="" readonly/>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="8">
            <el-form-item label="分部" prop="branch">
              <el-input v-model="form.branch" placeholder="" readonly/>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="组别" prop="zb">
              <el-input v-model="form.zb" placeholder="" readonly/>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="岗位" prop="jobs">
              <el-input v-model="form.jobs" placeholder="" readonly/>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="8">
            <el-form-item label="入职日期" prop="rzDate">
              <el-date-picker clearable
                              v-model="form.rzDate"
                              type="date"
                              readonly
                              value-format="yyyy-MM-dd"
                              placeholder="请选择入职日期">
              </el-date-picker>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="考勤日期" prop="kqDate" >
              <el-date-picker clearable @change="changeKqDate"
                              v-model="form.kqDate"
                              type="month"
                              value-format="yyyy-MM"
                              placeholder="请选择考勤日期">
              </el-date-picker>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="应出勤天数" prop="ycqDay">
              <el-input v-model="form.ycqDay" placeholder="请输入应出勤天数"/>
            </el-form-item>
          </el-col>
        </el-row>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="submitForm">确 定</el-button>
        <el-button @click="cancel">取 消</el-button>
      </div>
    </el-dialog>
    <el-dialog :title="upload.title" :visible.sync="upload.open" width="400px" append-to-body>
      <el-upload
        ref="upload"
        :limit="1"
        accept=".xlsx, .xls"
        :headers="upload.headers"
        :action="upload.url + '?updateSupport=' + upload.updateSupport"
        :disabled="upload.isUploading"
        :on-progress="handleFileUploadProgress"
        :on-success="handleFileSuccess"
        :auto-upload="false"
        drag
      >
        <i class="el-icon-upload"></i>
        <div class="el-upload__text">将文件拖到此处，或<em>点击上传</em></div>
        <div class="el-upload__tip text-center" slot="tip">
          <!--  <div class="el-upload__tip" slot="tip">
              <el-checkbox v-model="upload.updateSupport" /> 是否更新已经存在的用户数据
            </div>-->
          <span>仅允许导入xls、xlsx格式文件。</span>
          <el-link type="primary" :underline="false" style="font-size:12px;vertical-align: baseline;"
                   @click="importTemplate">下载模板
          </el-link>
        </div>
      </el-upload>
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="submitFileForm">确 定</el-button>
        <el-button @click="upload.open = false">取 消</el-button>
      </div>
    </el-dialog>
  </div>
</template>

<script>
import {
  listRgAttend,
  getRgAttend,
  delRgAttend,
  addRgAttend,
  updateRgAttend,
  deleteNcAttendRgByIdentyCode, editById
} from "@/api/hr/rgAttend";
import {getToken} from "@/utils/auth";
import PersonSelect  from "@/components/personSelect/index";
import {listAttendBase} from "@/api/hr/attendBase";
import moment from "moment/moment";



export default {
  name: "RgAttend",
  components :{PersonSelect},
  dicts: ['wr_type'],
  data() {
    return {
      // 遮罩层
      loading: true,
      // 选中数组
      ids: [],
      identyCodes: [],
      emoName: [],
      kqTime: [],
      // 非单个禁用
      single: true,
      // 非多个禁用
      multiple: true,
      // 显示搜索条件
      showSearch: true,
      // 总条数
      total: 0,
      // 人工考勤表格数据
      rgAttendList: [],
      // 弹出层标题
      title: "",
      // 是否显示弹出层
      open: false,
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 10,
        gcName: null,
        employeeName: null,
        jobNumber: null,
        department: null,
        branch: null,
        rzDate: null,
        zb: null,
        jobs: null,
        kqDate: null,
        day1: null,
        day2: null,
        day3: null,
        day4: null,
        day5: null,
        day6: null,
        day7: null,
        day8: null,
        day9: null,
        day10: null,
        day11: null,
        day12: null,
        day13: null,
        day14: null,
        day15: null,
        day16: null,
        day17: null,
        day18: null,
        day19: null,
        day20: null,
        day21: null,
        day22: null,
        day23: null,
        day24: null,
        day25: null,
        day26: null,
        day27: null,
        day28: null,
        day29: null,
        day30: null,
        day31: null,
        actDays: null,
        jjrTime: null,
        jbTime: null,
        tbTime: null,
        sdTime: null,
        restDay: null,
        leaveDay: null,
        lunDay: null,
        xlzqqDay: null,
        ycqDay: null
      },
      upload: {
        // 是否显示弹出层（物料导入）
        open: false,
        // 弹出层标题（物料导入）
        title: "导入`rgAttend`信息",
        // 是否禁用上传
        isUploading: false,
        // 是否更新已经存在的用户数据
        updateSupport: 0,
        // 设置上传的请求头部
        headers: {Authorization: "Bearer " + getToken()},
        // 上传的地址
        url: process.env.VUE_APP_BASE_API + "/hr/rgAttend/importData"
      },
      // 表单参数
      form: {},
      // 表单校验
      rules: {
        jobNumber: [
          { required: true, trigger: "blur", message: "请选择员工" },
        ],
        kqDate: [
          { required: true, trigger: "blur", message: "请输入考勤日期" },
        ],
      }
    };
  },
  created() {
    this.getList();
  },
  methods: {
    objectSpanMethod({ row, column, rowIndex, columnIndex }) {
      if (columnIndex === 0 ||columnIndex === 1||columnIndex === 2||
        columnIndex === 3||columnIndex === 4||columnIndex === 5||columnIndex === 6||
        columnIndex === 7||columnIndex === 8||columnIndex === 9 ||columnIndex === 41||columnIndex === 42
        ||columnIndex === 43||columnIndex ===44||columnIndex === 45||columnIndex ===46||columnIndex === 47
        ||columnIndex === 48||columnIndex === 49 ||columnIndex === 50||columnIndex === 51||columnIndex === 52) {
        if (rowIndex % 2 === 0) {
          return {
            rowspan: 2,
            colspan: 1
          };
        } else {
          return {
            rowspan: 0,
            colspan: 0
          };
        }
      }
    },
    /** 查询人工考勤列表 */
    getList() {
      this.loading = true;
      listRgAttend(this.queryParams).then(response => {
        this.rgAttendList = response.rows;
        this.total = response.total;
        this.loading = false;
      });
    },
    // 取消按钮
    cancel() {
      this.open = false;
      this.reset();
    },
    // 表单重置
    reset() {
      this.form = {
        id: null,
        gcCode: null,
        gcName: null,
        employeeName: null,
        jobNumber: null,
        department: null,
        branch: null,
        rzDate: null,
        zb: null,
        jobs: null,
        kqDate: new Date(),
        day1: null,
        day2: null,
        day3: null,
        day4: null,
        day5: null,
        day6: null,
        day7: null,
        day8: null,
        day9: null,
        day10: null,
        day11: null,
        day12: null,
        day13: null,
        day14: null,
        day15: null,
        day16: null,
        day17: null,
        day18: null,
        day19: null,
        day20: null,
        day21: null,
        day22: null,
        day23: null,
        day24: null,
        day25: null,
        day26: null,
        day27: null,
        day28: null,
        day29: null,
        day30: null,
        day31: null,
        actDays: null,
        createBy: null,
        createTime: null,
        updateBy: null,
        updateTime: null,
        jjrTime: null,
        jbTime: null,
        tbTime: null,
        sdTime: null,
        restDay: null,
        leaveDay: null,
        lunDay: null,
        xlzqqDay: null,
        ycqDay: null
      };
      this.resetForm("form");
    },
    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.pageNum = 1;
      this.getList();
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.resetForm("queryForm");
      this.handleQuery();
    },
    // 多选框选中数据
    handleSelectionChange(selection) {
      console.log(selection,"selection")
      this.identyCodes = selection.map(item => item.identificationCode)
      this.ids = selection.map(item => item.id)
      this.emoName = selection.map(item => item.employeeName)
      this.kqTime = selection.map(item => item.kqDate)
      this.single = selection.length !== 1
      this.multiple = !selection.length
    },
    /** 新增按钮操作 */
    handleAdd() {
      this.reset();
      this.open = true;
      this.title = "添加人工考勤";
      this.changeKqDate()
    },
    /** 修改按钮操作 */
    handleUpdate(row) {
      this.reset();
      const id = row.id || this.ids
      getRgAttend(id).then(response => {
        this.form = response.data;
        this.open = true;
        this.title = "修改人工考勤";
      });
    },
    /** 提交按钮 */
    submitForm() {
      this.$refs["form"].validate(valid => {
        if (valid) {
          if (this.form.id != null) {
            updateRgAttend(this.form).then(response => {
              this.$modal.msgSuccess("修改成功");
              this.open = false;
              this.getList();
            });
          } else {
            addRgAttend(this.form).then(response => {
              this.$modal.msgSuccess("新增成功");
              this.open = false;
              this.getList();
            });
          }
        }
      });
    },
    /** 删除按钮操作 */
    handleDelete(row) {
      const codes = row.identificationCode || this.identyCodes;
      let name = row.employeeName ||this.emoName;
      let kq = row.kqDate ||this.kqTime;
      this.$modal.confirm('是否确认删除员工姓名为【"' + name + '"】，考勤日期为【'+kq+'】的数据项？').then(function () {
        return deleteNcAttendRgByIdentyCode(codes);
      }).then(() => {
        this.getList();
        this.$modal.msgSuccess("删除成功");
      }).catch(() => {
      });
    },
    /** 导出按钮操作 */
    handleExport() {
      this.download('hr/rgAttend/export', {
        ...this.queryParams
      }, `rgAttend_${new Date().getTime()}.xlsx`)
    },
    /** 导入按钮操作 */
    handleImport() {
      this.upload.title = "`人工考勤导入";
      this.upload.open = true;
    },
    /** 下载模板操作 */
    importTemplate() {
      this.download('hr/rgAttend/importTemplate', {}, `人工考勤模板.xlsx`)
    },
    // 文件上传中处理
    handleFileUploadProgress(event, file, fileList) {
      this.upload.isUploading = true;
    },
    // 文件上传成功处理
    handleFileSuccess(response, file, fileList) {
      this.upload.open = false;
      this.upload.isUploading = false;
      this.$refs.upload.clearFiles();
      this.$alert("<div style='overflow: auto;overflow-x: hidden;max-height: 70vh;padding: 10px 20px 0;'>" + response.msg + "</div>", "导入结果", {dangerouslyUseHTMLString: true});
      this.getList();
    },
    // 提交上传文件
    submitFileForm() {
      this.$refs.upload.submit();
    },
    handleSelectPerson(){
      this.$refs.personSelect.showFlag = true;
    },
    onPersonSelected(obj){
      if(obj != undefined && obj != null){
        this.form.jobNumber = obj.jobNo;
        this.form.employeeName = obj.pname;
        this.form.department = obj.department;
        this.form.branch = obj.branch;
        this.form.zb = obj.pgroup;
        this.form.jobs = obj.jobs;
        this.form.rzDate = obj.entryDate;
      }
    },
    wrChangeMethod(id,val,name){
      let param = {[name]:val};
      param.id = id;
      param.tag = name;
      editById(param).then(response => {
        this.$modal.msgSuccess("修改成功");
        this.getList();
      });
    },
    changeKqDate(){
      let kqdate = moment.utc(this.form.kqDate).local().format('YYYYMM')
      let param = {
        yearN:kqdate
      }
      listAttendBase(param).then(response => {
        this.form.ycqDay = response.rows[0].ycqts
      });
    }
  }
};
</script>
<style lang="scss" scoped>
::v-deep .cell .el-input__inner{
  border:none;
}
</style>
